<template>
  <div>
    <el-dialog
      title="引用列表"
      :visible.sync="dialogVisible"
      width="1000px"
      :lock-scroll="false"
    >
      <div class="download-list" style="min-height: 400px">
        <el-table :data="tableData" stripe style="width: 100%" size="mini">
          <el-table-column prop="fileName" label="资源名称" width="180">
          </el-table-column>
          <el-table-column prop="fileSize" label="资源大小" width="120">
            <template slot-scope="scope">
              {{ scope.row.fileSize | fileSizeFilter }}
            </template>
          </el-table-column>
          <el-table-column prop="gradeName" label="引用">
            <template slot-scope="{ row }">
              {{ row.semesterName }} {{ row.gradeName }} {{ row.className }}
            </template>
          </el-table-column>
          <el-table-column prop="updateTime" label="创建时间" width="180">
          </el-table-column>
        </el-table>
        <Pagination
          v-show="parseInt(pageObj.count) > 0"
          :total="parseInt(pageObj.count)"
          @change="getList"
          :page.sync="listQuery.page"
          :limit.sync="listQuery.limit"
        />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { eduResourceQuoteQuery } from "@/api/admin/teach/eduResourceQuote.js";
import Bus from "@/utils/bus.js";
export default {
  data() {
    return {
      dialogVisible: false,
      listQuery: {
        page: 1,
        limit: 10,
        fileId: "",
      },
      tableData: [],
      pageObj: {},
    };
  },
  mounted() {
    Bus.$on("showDialogQuote", (v) => {
      this.listQuery.fileId = v.fileId;
      this.getList();
    });
  },
  beforeDestroy() {
    Bus.$off("showDialogQuote");
  },
  methods: {
    getList() {
      if (!this.listQuery.fileId) return;
      eduResourceQuoteQuery(this.listQuery).then((res) => {
        this.tableData = res.data.data;
        this.pageObj = res.data;
        this.dialogVisible = true;
      });
    },
  },
};
</script>